#ifndef LOMBINARYINSTREAMHH
#define LOMBINARYINSTREAMHH
#include "lom-in-stream.hh"
#include "lom-property.hh"

namespace licada { class IBinaryInStream; }

namespace lom
{
    class ILomValueFactory;
    class ILomIncomingHandleMap;
    /**
       Conversion of licada and leam types to binary format.
       Enumerations are 1 byte, most other things are direct
       little endian conversions.  Lengths are stored as
       4 byte unsigned litte endian integers.
       
       All handles that are read are sent through streamToWorld
       in the ILomIncomingHandleMap.  This allows an outside
       entity to control the handle-translation mechanism.
    */
    class LomBinaryInStream : public ILomInStream
    {
	ILomValueFactory* factory;
	LomClassManager* clsManager;
	ILomIncomingHandleMap* incomingMap;
	THandle tempHandle;
	THandleVector tempHandleV;
	licada::TNameStr tempStr;
	licada::IBinaryInStream* inStream;
	
    public:
	LomBinaryInStream( licada::IBinaryInStream* proxy = NULL
			   , lom::ILomValueFactory* _factory = NULL
			   , lom::LomClassManager* _clsManager = NULL
			   , ILomIncomingHandleMap* _incomingMap = NULL ) 
	    : inStream( proxy )
	      , factory( _factory )
	      , clsManager( _clsManager )
	      , incomingMap( _incomingMap )
	    {}
	virtual ~LomBinaryInStream(){}
	
	virtual void setup( licada::IBinaryInStream* proxy
			    , ILomValueFactory* _factory
			    , LomClassManager* _clsManager
			    , ILomIncomingHandleMap* _incomingMap ) { 
	    inStream = proxy; 
	    factory = _factory;
	    clsManager = _clsManager;
	    incomingMap = _incomingMap;
	}
	
	virtual void operator>>( lom::EDataType& dtype );
	
	virtual void operator>>( bool& val );
	virtual void operator>>( double& val );

	virtual void operator>>( licada::uint8& val );
	virtual void operator>>( licada::uint16& val );
	virtual void operator>>( licada::uint32& val );
	virtual void operator>>( licada::int64& val );
	
	//These are defined in terms of the above operators
	virtual void operator>>( licada::TDoubleVector& val );
	virtual void operator>>( licada::TUInt32Vector& val );
	virtual void operator>>( licada::TInt64Vector& val );
	virtual void operator>>( licada::TString& val );
	virtual void operator>>( licada::TStringVector& val );
	virtual void operator>>( licada::TDataVector& val );
	virtual void operator>>( licada::TNameStr& val );
	
	virtual void operator>>( lom::LomValue*& val ); 
	virtual void operator>>( lom::TValueVector& val);
	virtual void operator>>( lom::LomInstance& val );
	virtual void operator>>( lom::LomClass& val );
	virtual void operator>>( lom::TPropertyVector& val );
    };    
}
#endif
